package com.lanchetech.user.controller;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.entity.Article;
import com.lanchetech.entity.CompanyIntroduction;
import com.lanchetech.user.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "文章接口", tags = "文章接口")
@RequestMapping("/api/article")
@RestController
public class ArticleController {

    @Autowired
    ArticleService articleService;

    @ApiOperation("获取文章内容")
    @GetMapping("/getArticle")
    public ResultData<Article> getArticle(@RequestParam("id") Long id) {
        return articleService.getArticle(id);
    }


    @ApiOperation("获取指定目录下的文章分页")
    @PostMapping("/getArticlePageByCatalog")
    public ResultData<BasePageResp<Article>> getArticlePageByCatalog(@RequestBody PageReq req) {
        return articleService.getArticlePageByCatalog(req);
    }

    @ApiOperation("获取作用文章")
    @GetMapping("/getEffectArticle")
    public ResultData<Article> getEffectArticle(@RequestParam("effect") String effect) {
        return articleService.getEffectArticle(effect);
    }

    @ApiOperation("获取公司简介")
    @GetMapping("/getCompanyIntroduction")
    public ResultData<CompanyIntroduction> getCompanyIntroduction() {
        return articleService.getCompanyIntroduction();
    }
}
